﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Cmd.aspx.cs" Inherits="WebApplication1.MemberShip.command" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        #txtCommand
        {
            height: 118px;
            width: 410px;
        }
        .style1
        {
            width: 340px;
            text-align: center;
        }
    </style>
    <script type="text/javascript">
        function TestPort() {
            var deName = document.getElementById('<%= txtDemanName.ClientID %>').value;
            var port = document.getElementById('<%= txtPort.ClientID %>').value;
            var regI = /^[1-9]\d+$/;
            var portNunm = parseFloat(port);
            if (isNaN(portNunm)
                || (!(portNunm <= 65535 && port >= 1))
                || (!regI.test(port))
            ) {
                alert("端口必须是1~65535的整数！");
                return false;
            }
            var regD = /^((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)(\.((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]\d)|\d)){3}$|^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/;
            if (
             !regD.test(deName)
            ) {
                alert("域名的格式不正确！");
                return false;
            }
            return true;
        }
        
    </script>
</head>
<body style="font-size: 12px;">
    <form id="form1" runat="server">
    <div>
        <textarea id="txtCommand" runat="server"></textarea><br />
        <asp:Button ID="btnSubmit" runat="server" Text="提交" OnClick="btnSubmit_Click" />
        <div id="divMenu" runat="server">
            <fieldset>
                <legend>尝试连接服务器</legend>
                <table>
                    <tr>
                        <td>
                            域名：
                        </td>
                        <td>
                            <asp:TextBox ID="txtDemanName" runat="server" Text="open.weixin.qq.com" Width="238px">open.weixin.qq.com</asp:TextBox>
                        </td>
                        <td>
                            端口
                        </td>
                        <td>
                            <asp:TextBox ID="txtPort" runat="server" Width="45px" Text="443"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Button ID="btnTestPort" runat="server" Text="测试连接" OnClick="btnTestPort_Click"
                                OnClientClick="return TestPort();" />
                        </td>
                    </tr>
                </table>
                <div style="height: 10px;">
                </div>
                <div>
                    测试结果如下：</div>
                <table border="1">
                    <tr>
                        <td class="style1">
                            域名
                        </td>
                        <td>
                            端口
                        </td>
                        <td>
                            TCP
                        </td>
                        <td>
                            UDP
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            <asp:Label Text="" ID="lbDemainName" runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="lbPort" Text="" runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="lbTcp" Text="" runat="server" />
                        </td>
                        <td>
                            <asp:Label ID="lbUdp" Text="" runat="server" />
                        </td>
                    </tr>
                </table>
                <asp:Label Text="" ID="lbError" ForeColor="Red" runat="server" />
                <br />
                <span>说明：如果TCP和UDP端口正常则说明出站规则允许访问指定端口正常。但不能说明入站规则，<br />
                    因为入站规则只能通过远端进行测试。</span>
                <br />
                <asp:Button runat="server" ID="btnHiddenTestPort" Text="退出" OnClick="btnHiddenTestPort_Click" />
            </fieldset>
        </div>
    </div>
    </form>
</body>
</html>
